home *** CD-ROM | disk | FTP | other *** search
- Path: news.informatik.uni-muenchen.de!usenet
- From: Kurt Watzka <watzka@stat.uni-muenchen.de>
- Newsgroups: comp.lang.c
- Subject: Re: realloc(NULL,100)
- Date: Thu, 29 Feb 1996 13:47:48 +0100
- Organization: Institut fⁿr Statistik
- Message-ID: <3135A074.640C@stat.uni-muenchen.de>
- References: <31346CB0.41C67EA6@jupiter.di.uminho.pt>
- NNTP-Posting-Host: pc7.stat.uni-muenchen.de
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (WinNT; I)
-
- Rui Bastos wrote:
-
-
- > Does anybody knows what's the expected behaviour of this program?
- >
- > #include <stdio.h>
- > #include <malloc.h>
-
- Who knows what your non-standard header <malloc.h> contains.
- Maybe it defines something like
-
- #define realloc(x, y) exit(*x - y)
-
- Is there a specific reason _not_ to include <stdlib.h> if
- you want to use realloc()?
-
- >
- > main()
- > {
- > void *x=NULL;
- > x=realloc(NULL,100);
- > printf("%p\n",x);
- > }
- >
- > I tested it under diferent compilers/operating systems
- > and it returns null, others returns a valid address and other
- > crashes.
- >
-
- The expected behaviour with a _correct_ prototype for
- realloc() in scope is that "realloc() behaves like
- malloc() if the first parameter is NULL", so both
- returning NULL and a valid address are within the realms
- of "expected behaviour".
-
- > PS please and send me an email if you reply to this post.
-
- If you want to reduce the noise level on this newsgroup,
- ask for email replies _and_ offer to post a summary of
- the answers you get.
-
- There is a good reason _not_ to ask for private email replies.
- Sometimes the person that replies is _very_ wrong in his/her
- relpy. The collective wisdom of c.l.c will almost certainly
- spot inaccuracies in an answer and correct them.
-
- Kurt
-